package guowenlong.golf.ui.friend;


import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.widget.Button;
import butterknife.BindView;
import butterknife.OnClick;
import guowenlong.golf.R;
import guowenlong.golf.base.BaseFragment;
import guowenlong.golf.ui.friend.myfriends.MyFriendFragment;
import guowenlong.golf.ui.friend.myfriends.SearchFriendsActivity;
import guowenlong.golf.ui.friend.myteam.MyTeamFragment;
import guowenlong.golf.ui.home.TabAdapter;
import java.util.ArrayList;
import java.util.List;

/**
 * des   : 描述 author: Administrator email : guowenlong20000@gmail.com time  : 2017年02月10日 下午 3:19.
 */

public class FriendFragment extends BaseFragment {

  @BindView(R.id.btn_search)
  Button btnNotify;
  @BindView(R.id.tl_friend)
  TabLayout tlHome;
  @BindView(R.id.vp_friend)
  ViewPager vpView;
  private FragmentPagerAdapter fAdapter;                               //定义adapter

  private List<Fragment> list_fragment;                                //定义要装fragment的列表
  private List<String> list_title;                                     //tab名称列表

  private MyFriendFragment mMyFriendFragment;
  private MyTeamFragment mMyTeamFragment;

  @Override
  public void initData(Bundle savedInstanceState) {

  }

  @Override
  public void initView() {
    mMyFriendFragment = new MyFriendFragment();
    mMyTeamFragment = new MyTeamFragment();

    list_fragment = new ArrayList<>();
    list_fragment.add(mMyFriendFragment);
    list_fragment.add(mMyTeamFragment);

    list_title = new ArrayList<>();
    list_title.add("我的好友");
    list_title.add("我的球队");
    tlHome.setTabMode(TabLayout.MODE_FIXED);
    tlHome.addTab(tlHome.newTab().setText(list_title.get(0)));
    tlHome.addTab(tlHome.newTab().setText(list_title.get(1)));

    fAdapter = new TabAdapter(getActivity().getSupportFragmentManager(), list_fragment, list_title);
    vpView.setAdapter(fAdapter);
    tlHome.setupWithViewPager(vpView);
  }

  @Override
  public int getLayoutId() {
    return R.layout.fragment_friend;
  }

  @OnClick(R.id.btn_search)
  public void onViewClicked() {
    startActivity(new Intent(getActivity(),SearchFriendsActivity.class));
  }
}